import request from '../utils/request';
import { stringify } from 'qs';
import { baseServerUrl } from '../utils/Constant';

export async function entryOrderPage(params) {
  return request(`${baseServerUrl}/tms/tms-order/entry-page?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function entryOrderSaveOrUpdate(params) {
  const { orderId } = params;
  let method = 'PUT';
  if (orderId === 0) {
    method = 'POST';
    delete params['id'];
  }
  return request(`${baseServerUrl}/tms/tms-order/entry`, {
    method: method,
    body: {
      ...params,
    },
  });
}

export async function entryDel(params) {
  return request(`${baseServerUrl}/tms/tms-order/entry`, {
    method: 'DELETE',
    body: params,
  });
}

export async function entrySubmit(params) {
  return request(`${baseServerUrl}/tms/tms-order/entry-submit`, {
    method: 'POST',
    body: params,
  });
}

export async function trackOrderPage(params) {
  return request(`${baseServerUrl}/tms/tms-order/track-page?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function trackPass(params) {
  return request(`${baseServerUrl}/tms/tms-order/track-pass`, {
    method: 'POST',
    body: params,
  });
}

export async function trackReject(params) {
  return request(`${baseServerUrl}/tms/tms-order/track-reject`, {
    method: 'POST',
    body: params,
  });
}

export async function incomePage(params) {
  return request(`${baseServerUrl}/tms/tms-order/income-page?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function incomeAuditPage(params) {
  return request(`${baseServerUrl}/tms/tms-order/income-audit-page?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function invoicePage(params) {
  return request(`${baseServerUrl}/tms/tms-order/invoice-page?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function incomeSave(params) {
  return request(`${baseServerUrl}/tms/tms-order/income-save`, {
    method: 'POST',
    body: params,
  });
}

export async function incomeAudit(params) {
  return request(`${baseServerUrl}/tms/tms-order/income-audit`, {
    method: 'POST',
    body: params,
  });
}

export async function incomeReject(params) {
  return request(`${baseServerUrl}/tms/tms-order/income-reject`, {
    method: 'POST',
    body: params,
  });
}

export async function incomeSubmit(params) {
  return request(`${baseServerUrl}/tms/tms-order/income-submit`, {
    method: 'POST',
    body: params,
  });
}

export async function checkInvoice(params) {
  return request(`${baseServerUrl}/tms/tms-invoice/check`, {
    method: 'POST',
    body: params,
  });
}

export async function invoice(params) {
  return request(`${baseServerUrl}/tms/tms-invoice`, {
    method: 'POST',
    body: params,
  });
}
